package androidgames.networkgames.screens;

import java.io.IOException;

import android.util.Log;
import androidgames.configs.UIConfig;
import androidgames.networkgames.screens.components.DrawableButton;
import androidgames.networkgames.screens.components.DrawableComponent;
import androidgames.networkgames.screens.components.DrawableComponent.CEvent;
import androidgames.networkgames.screens.components.DrawableComponent.IEventListener;
import com.badlogic.androidgames.framework.Game;
import com.badlogic.androidgames.framework.Graphics.PixmapFormat;
import com.badlogic.androidgames.framework.Pixmap;

public class LoginScreen extends NetworkScreen implements IEventListener {
	DrawableButton btnExit;
	DrawableButton btn2;
	public LoginScreen(Game game) {
		super(game);
		// TODO Auto-generated constructor stub
		background = g.newPixmap(UIConfig.LOGIN_BACKGROUND, PixmapFormat.RGB565);
		Pixmap exit = g.newPixmap("UI/button/bg_exit_arraw.png", PixmapFormat.RGB565);
		btnExit = new DrawableButton(this, exit, exit.getWidth(), exit.getHeight(), 706, 391, 0, 0, "",0,0);
		btn2 = new DrawableButton(this, exit, exit.getWidth(), exit.getHeight(), 500, 391, 0, 0, "",0,0);
		addComponent(btnExit);
		addComponent(btn2);
	}

	@Override
	public void onDataReceive(byte[] data) throws IOException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void handlePacket(byte[] data) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void update(float deltaTime)
	{
		super.update(deltaTime);
	}
	
	@Override
	public void present(float deltaTime)
	{
		super.present(deltaTime);
	}

	@Override
	public void onTouch(DrawableComponent view, CEvent event) {
		// TODO Auto-generated method stub
		if(view.equals(btnExit))
		{
			if(event.iEventType == CEvent.TOUCH)
			{
				Log.d("touch test", "Button " + view.toString());
				return;
			}
			
			if(event.iEventType == CEvent.LONG_TOUCH)
			{
				Log.d("touch test", "Long touch " + view.toString());
			}
			
			if(event.iEventType == CEvent.DOUBLE_TOUCH)
			{
				Log.d("touch test", "Double touch " + view.toString());
			}
		}	
		
		if(view.equals(btn2))
		{
			if(event.iEventType == CEvent.TOUCH)
			{
				Log.d("touch test", "Button " + view.toString());
				return;
			}
			
			if(event.iEventType == CEvent.LONG_TOUCH)
			{
				Log.d("touch test", "Long touch " + view.toString());
			}
		}	
	}

	@Override
	public void addComponent(DrawableComponent component) {
		// TODO Auto-generated method stub
		component.addTouchListener(this);
		componentList.add(component);
	}

}
